<template>
  <a-card :bordered="false" :body-style="{ padding: '10px 0px 10px 0px' }">
    <!-- 查询区域 -->
    <!--    <div class="table-page-search-wrapper">-->
    <!--      <a-form layout="inline" @keyup.enter.native="searchQuery">-->
    <!--        <a-row :gutter="24">-->
    <!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--            <a-form-item label="经办人">-->
    <!--              <a-input placeholder="请输入经办人" v-model="queryParam.handlerId"></a-input>-->
    <!--            </a-form-item>-->
    <!--          </a-col>-->
    <!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--            <a-form-item label="经办部门">-->
    <!--              <a-input placeholder="请输入经办部门" v-model="queryParam.handlerDeptId"></a-input>-->
    <!--            </a-form-item>-->
    <!--          </a-col>-->
    <!--          <template v-if="toggleSearchStatus">-->
    <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--              <a-form-item label="印章编号">-->
    <!--                <a-input placeholder="请输入印章编号" v-model="queryParam.sealQualificationId"></a-input>-->
    <!--              </a-form-item>-->
    <!--            </a-col>-->
    <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--              <a-form-item label="名称">-->
    <!--                <a-input placeholder="请输入名称" v-model="queryParam.name"></a-input>-->
    <!--              </a-form-item>-->
    <!--            </a-col>-->
    <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--              <a-form-item label="印章类别">-->
    <!--                <j-dict-select-tag placeholder="请选择印章类别" v-model="queryParam.sealType" dictCode="yzlx_type"/>-->
    <!--              </a-form-item>-->
    <!--            </a-col>-->
    <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--              <a-form-item label="状态">-->
    <!--                <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="seal_status_type"/>-->
    <!--              </a-form-item>-->
    <!--            </a-col>-->
    <!--          </template>-->
    <!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
    <!--            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">-->
    <!--              <a-button type="primary" @click="searchQuery(),showeal()" icon="search">查询</a-button>-->
    <!--              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>-->
    <!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
    <!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
    <!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
    <!--              </a>-->
    <!--            </span>-->
    <!--          </a-col>-->
    <!--        </a-row>-->
    <!--      </a-form>-->
    <!--    </div>-->
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <!--    <div class="table-operator">-->
    <!--      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpSealCertificateFileManage:add')">新增</a-button>-->
    <!--      <a-button type="primary" icon="download" @click="handleExportXls('印章档案管理')" :disabled="isDisabledAuth('erpSealCertificateFileManage:export')">导出</a-button>-->
    <!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
    <!--        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpSealCertificateFileManage:import')">导入</a-button>-->
    <!--      </a-upload>-->
    <!--      &lt;!&ndash; 高级查询区域 &ndash;&gt;-->
    <!--      &lt;!&ndash;<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>&ndash;&gt;-->
    <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
    <!--        <a-menu slot="overlay">-->
    <!--          <a-menu-item key="1" @click="batchDel" :disabled="isDisabledAuth('erpSealCertificateFileManage:delete')"><a-icon type="delete"/>删除</a-menu-item>-->
    <!--        </a-menu>-->
    <!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
    <!--      </a-dropdown>-->
    <!--      <a-popover title="自定义列" trigger="click" placement="leftBottom">-->
    <!--        <template slot="content">-->
    <!--          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">-->
    <!--            <a-row>-->
    <!--              <template v-for="(item,index) in defColumns">-->
    <!--                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">-->
    <!--                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>-->
    <!--                </template>-->
    <!--              </template>-->
    <!--            </a-row>-->
    <!--          </a-checkbox-group>-->
    <!--        </template>-->
    <!--        <a style="float: right;"><a-icon type="setting" :style='iconStyle'/></a>-->
    <!--      </a-popover>-->
    <!--    </div>-->

    <!-- table区域-begin -->
    <div>
      <!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
      <!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
      <!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
      <!--      </div>-->

      <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="sealList"
          :pagination="false"
          :loading="loading"
          class="j-table-force-nowrap"
          @change="handleTableChange">
          <span slot="sealType" :title="text" slot-scope="text, record">{{ record.sealType_dictText?record.sealType_dictText: record.sealType }}</span>
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
              v-else
              :ghost="true"
              type="primary"
              icon="download"
              size="small"
              @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
<!--            <a-button-->
          <!--                class="ruleButton"-->
          <!--                :ghost="true"-->
          <!--                type="primary"-->
          <!--                icon="edit"-->
          <!--                @click="handleEdit(record)"-->
          <!--                :disabled="isDisabledAuth('erpSealCertificateFileManage:edit')"-->
          <!--        />-->
        <a-divider type="vertical"/>
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a-button
                class="ruleButton"
                :ghost="true"
                type="primary"
                icon="delete"
                :disabled="isDisabledAuth('erpSealCertificateFileManage:delete')"/>
        </a-popconfirm>
        </span>

      </a-table>
    </div>

    <erp-seal-certificate-file-manage-modal ref="modalForm" @ok="modalFormOk"></erp-seal-certificate-file-manage-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpSealCertificateFileManageModal from './modules/ErpSealCertificateFileManageModalZz'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

export default {
  name: 'ErpSealCertificateFileManageList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    ErpSealCertificateFileManageModal,
  },
  data() {
    return {
      description: '印章档案管理管理页面',
      //表头
      columns: [],
      //列设置
      settingColumns: [],
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '印章编号',
          align: 'center',
          dataIndex: 'sealQualificationId',
        },
        {
          title: '名称',
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: '印章类别',
          align: 'center',
          dataIndex: 'sealType',
          scopedSlots: { customRender: 'sealType' },
        },
        {
          title: '印章管理员',
          align: 'center',
          dataIndex: 'handlerId',
        },
        {
          title: '申请部门',
          align: 'center',
          dataIndex: 'handlerDeptId',
        },
        /* {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }, */
      ],
      url: {
        list: '/api/erp/administration/seal/erpSealCertificateFileManage/list',
        delete: '/api/erp/administration/seal/erpSealCertificateFileManage/delete',
        deleteBatch: '/api/erp/administration/seal/erpSealCertificateFileManage/deleteBatch',
        exportXlsUrl: '/api/erp/administration/seal/erpSealCertificateFileManage/exportXls',
        importExcelUrl: 'administration/seal/erpSealCertificateFileManage/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
      sealList: [],
      disableMixinCreated:true,
    }
  },
  created() {

    //this.getSuperFieldList();
    this.initColumns();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    handleDelete(id) {
      for (let i = 0; i < this.sealList.length; i++) {
        if (this.sealList[i].id == id) {
          this.sealList.splice(i, 1);
        }
      }
      var data = '';
      for (let i = 0; i < this.sealList.length; i++) {
        data += ',' + this.sealList[i].id;
      }
      this.$emit('cCopy', data);
    },
    showeal() {
      console.log('FileMound', this.sealList);
    },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'datetime', value: 'createTime', text: '创建日期' })
      fieldList.push({ type: 'string', value: 'handlerId', text: '经办人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'handlerDeptId', text: '经办部门', dictCode: '' })
      fieldList.push({ type: 'string', value: 'sealQualificationId', text: '印章编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'name', text: '名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'sealType', text: '印章类别', dictCode: 'yzlx_type' })
      fieldList.push({
        type: 'string',
        value: 'sealCompany',
        text: '印章所属公司',
        dictCode: 'erp_company_files,file_name,id'
      })
      fieldList.push({ type: 'string', value: 'sealCertificationHead', text: '印章负责人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'authorizedPerson', text: '授权责任人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'delegate', text: '委托方', dictCode: 'erp_company_files,file_name,id' })
      fieldList.push({ type: 'string', value: 'trustee', text: '被委托方（印章保管人）', dictCode: 'erp_employee_file,name,id' })
      fieldList.push({ type: 'date', value: 'entrustDateStart', text: '委托开始时间' })
      fieldList.push({ type: 'date', value: 'entrustDateEnd', text: '委托结束时间' })
      fieldList.push({ type: 'string', value: 'sealCertificationUseScope', text: '印章使用范围', dictCode: '' })
      fieldList.push({ type: 'string', value: 'attentionMatters', text: '注意事项', dictCode: '' })
      fieldList.push({ type: 'string', value: 'upload', text: '上传附件', dictCode: '' })
      fieldList.push({ type: 'string', value: 'status', text: '状态', dictCode: 'seal_status_type' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
